{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1cd0ea7f-7d3b-4fe6-889b-3caabf1c29e3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T03:28:00.681707Z",
     "iopub.status.busy": "2024-01-13T03:28:00.681305Z",
     "iopub.status.idle": "2024-01-13T03:28:01.071392Z",
     "shell.execute_reply": "2024-01-13T03:28:01.070077Z",
     "shell.execute_reply.started": "2024-01-13T03:28:00.681673Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import openai\n",
    "import torch\n",
    "torch.cuda.is_available()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "961ce74f-b85e-4ae8-b0cc-d2f7d28a91a3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T03:28:01.804303Z",
     "iopub.status.busy": "2024-01-13T03:28:01.803489Z",
     "iopub.status.idle": "2024-01-13T03:28:01.809249Z",
     "shell.execute_reply": "2024-01-13T03:28:01.808060Z",
     "shell.execute_reply.started": "2024-01-13T03:28:01.804249Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "openai.api_base=\"http://localhost:8000/v1\"\n",
    "openai.api_key=\"none\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "1a243864-0657-4d41-b223-d988f31750e1",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2024-01-13T04:09:01.317640Z",
     "iopub.status.busy": "2024-01-13T04:09:01.317161Z",
     "iopub.status.idle": "2024-01-13T04:09:05.108634Z",
     "shell.execute_reply": "2024-01-13T04:09:05.107455Z",
     "shell.execute_reply.started": "2024-01-13T04:09:01.317605Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "messages=[\n",
    "        {\"role\":\"user\", \"content\":\"您好\"}\n",
    "    ]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "f9defb13-2607-429f-807d-b3a191dc7ae4",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2024-01-13T04:09:07.845392Z",
     "iopub.status.busy": "2024-01-13T04:09:07.844751Z",
     "iopub.status.idle": "2024-01-13T04:09:07.856970Z",
     "shell.execute_reply": "2024-01-13T04:09:07.851698Z",
     "shell.execute_reply.started": "2024-01-13T04:09:07.845351Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'您好！有什么我可以帮您的吗？'"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "c9a53a97-a1a1-474d-8f5b-d540fe3f6060",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T04:09:11.192221Z",
     "iopub.status.busy": "2024-01-13T04:09:11.191576Z",
     "iopub.status.idle": "2024-01-13T04:09:18.906678Z",
     "shell.execute_reply": "2024-01-13T04:09:18.905299Z",
     "shell.execute_reply.started": "2024-01-13T04:09:11.192173Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "messages=[\n",
    "        {\"role\":\"user\", \"content\":\"你好\"}\n",
    "    ]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "55f96d6b-754d-414d-ab59-f23601e4c550",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T04:09:30.725344Z",
     "iopub.status.busy": "2024-01-13T04:09:30.723966Z",
     "iopub.status.idle": "2024-01-13T04:09:30.733430Z",
     "shell.execute_reply": "2024-01-13T04:09:30.732015Z",
     "shell.execute_reply.started": "2024-01-13T04:09:30.725263Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'你好👋！我是人工智能助手 ChatGLM3-6B，很高兴见到你，欢迎问我任何问题。'"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "0106f024-19de-4f7a-aac2-aeeb4fda1870",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T04:10:11.524243Z",
     "iopub.status.busy": "2024-01-13T04:10:11.523382Z",
     "iopub.status.idle": "2024-01-13T04:10:32.632390Z",
     "shell.execute_reply": "2024-01-13T04:10:32.630797Z",
     "shell.execute_reply.started": "2024-01-13T04:10:11.524168Z"
    }
   },
   "outputs": [],
   "source": [
    "messages=[\n",
    "        {\"role\":\"user\", \"content\":\"请问什么是机器学习\"}\n",
    "    ]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "1d637253-72dd-42fd-90b3-ef20256c9a23",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T04:10:37.788605Z",
     "iopub.status.busy": "2024-01-13T04:10:37.787818Z",
     "iopub.status.idle": "2024-01-13T04:10:37.797691Z",
     "shell.execute_reply": "2024-01-13T04:10:37.796065Z",
     "shell.execute_reply.started": "2024-01-13T04:10:37.788536Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'机器学习是一种人工智能领域,旨在开发计算机程序,使计算机可以自动从数据中学习,并做出预测或做出决策,而不需要显式地编程。机器学习算法可以识别模式、进行分类、预测趋势、生成建议等。机器学习在许多领域得到广泛应用,如金融、医疗、营销、推荐系统等。'"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9bad87c7-060f-4a16-a5fc-a0f8d0ba0b97",
   "metadata": {},
   "source": [
    "- role system 用于身份设定\n",
    "- 用假设的方式在user中设定身份，模型可能会在后面对话中忘记自己身份\n",
    "- 在system中设定身份，模型记忆会更持久"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "b2a65099-7dff-4b85-9222-7b89ec03b51a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T04:42:31.495359Z",
     "iopub.status.busy": "2024-01-13T04:42:31.494756Z",
     "iopub.status.idle": "2024-01-13T04:43:38.412998Z",
     "shell.execute_reply": "2024-01-13T04:43:38.411428Z",
     "shell.execute_reply.started": "2024-01-13T04:42:31.495318Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'机器学习是人工智能的一个分支，它使计算机系统能够通过数据学习、识别模式并做出预测和决策，而无需显式地编程。机器学习算法通常基于统计学、数学和计算机科学领域的基础知识，可以应用于各种任务，例如图像和语音识别、自然语言处理、推荐系统、自动驾驶等。机器学习的核心思想是让计算机自动从数据中提取知识和规律，并利用这些知识来改进自身性能，这种自适应学习和自我优化的能力是机器学习的关键特征。'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages=[\n",
    "        {\"role\":\"user\", \"content\":\"假设你是一名资深大学教授，请问什么是机器学习\"}\n",
    "    ]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)\n",
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "bfd9d0e9-b63d-4155-8f19-aced761457c5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T04:44:50.667450Z",
     "iopub.status.busy": "2024-01-13T04:44:50.666502Z",
     "iopub.status.idle": "2024-01-13T04:45:15.238201Z",
     "shell.execute_reply": "2024-01-13T04:45:15.237146Z",
     "shell.execute_reply.started": "2024-01-13T04:44:50.667366Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'机器学习是人工智能的一个分支,旨在开发算法和模型,使计算机程序能够从数据中学习,并自主完成某些任务。机器学习通过监督学习、无监督学习和强化学习等方式,让计算机程序自动学习如何识别模式、做出预测和决策,而不需要人类手动编写规则或指令。机器学习在许多领域得到广泛应用,如图像识别、自然语言处理、推荐系统、金融风险管理等等。'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages=[\n",
    "        {\"role\":\"system\", \"content\":\"假设你是一名资深大学教授\"},\n",
    "        {\"role\":\"user\", \"content\":\"请问什么是机器学习\"}\n",
    "    ]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)\n",
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "ef19fb6e-0582-494f-b403-3ee0f3a462ee",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T04:50:56.499869Z",
     "iopub.status.busy": "2024-01-13T04:50:56.499242Z",
     "iopub.status.idle": "2024-01-13T04:51:33.350611Z",
     "shell.execute_reply": "2024-01-13T04:51:33.349366Z",
     "shell.execute_reply.started": "2024-01-13T04:50:56.499806Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'尊敬的各位亲朋好友，\\n\\n值此辞旧迎新之际，我谨代表我自己向您们致以最美好的祝愿！\\n\\n过去的一年，我们共同经历了无数的挑战与变化。在这辞旧迎新的时刻，回首过去，我们不禁为自己在困境中坚持和努力感到自豪。在新的一年里，让我们继续保持这种毅力，勇往直前，努力实现我们的目标。\\n\\n新的一年，希望我们的生活更加美好，工作更加顺利，身体健康，家庭和睦。让我们把握时光，共同创造一个充满希望和欢乐的新年！\\n\\n最后，再次祝愿您新年快乐，万事如意！\\n\\n此致，\\n敬礼！'"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages=[\n",
    "        {\"role\":\"system\", \"content\":\"假设你是一名资深的作家\"},\n",
    "        {\"role\":\"user\", \"content\":\"请帮我写一个新年贺词\"}\n",
    "    ]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)\n",
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "84d13190",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'尊敬的领导：\\n\\n值此新春佳节来临之际，我谨代表全体员工向您致以最诚挚的节日祝福！\\n\\n过去的一年，在您的英明领导下，我们共同努力，取得了骄人的成绩。公司的业务水平得到了进一步提升，市场份额不断扩大，员工的个人能力也得到了显著提高。这一切离不开您的正确决策和高效执行力。\\n\\n新的一年，我们将继续努力，为公司的发展做出更大的贡献。我们坚信，在您的带领下，我们一定能够创造更加辉煌的业绩。\\n\\n再次感谢您在过去一年里对我们的关心和帮助，祝您新年快乐，身体健康，工作顺利！\\n\\n此致\\n\\n敬礼！\\n\\n[您的名字]\\n\\n[日期]'"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages=[\n",
    "        {\"role\":\"system\", \"content\":\"假设你是一名企业员工\"},\n",
    "        {\"role\":\"user\", \"content\":\"请帮我写一个给领导的新年贺词\"}\n",
    "    ]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)\n",
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "055558be-7725-4fde-8ce7-e1bae695831e",
   "metadata": {},
   "source": [
    "# 模型推理能力测试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "55829da9-999f-4393-9d08-47e46a2a281d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T05:02:24.581666Z",
     "iopub.status.busy": "2024-01-13T05:02:24.581123Z",
     "iopub.status.idle": "2024-01-13T05:02:42.651053Z",
     "shell.execute_reply": "2024-01-13T05:02:42.650099Z",
     "shell.execute_reply.started": "2024-01-13T05:02:24.581631Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'他现在总共有15个网球。'"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages=[\n",
    "        {\"role\":\"user\", \"content\":\"罗杰有五个网球，他又买了两盒网球，每盒有3个网球，请问他现在总共有多少个网球\"}\n",
    "    ]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)\n",
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "7a4ee165-64a8-48c0-bd75-9eba82896700",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T05:06:19.204923Z",
     "iopub.status.busy": "2024-01-13T05:06:19.203940Z",
     "iopub.status.idle": "2024-01-13T05:06:44.539175Z",
     "shell.execute_reply": "2024-01-13T05:06:44.537854Z",
     "shell.execute_reply.started": "2024-01-13T05:06:19.204771Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'食堂开始有23个苹果。他们用掉了20个,所以现在食堂里剩下的苹果数量是23-20=3个苹果。然后他们又买了6个苹果,所以现在食堂总共有3+6=9个苹果。'"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages=[\n",
    "        {\"role\":\"user\", \"content\":\"食堂总共有23个苹果，如果他们用掉20个苹果，然后又买了6个苹果，请问现在食堂总共有多少个苹果\"}\n",
    "    ]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)\n",
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "e8e4d5dc-0bc2-4713-9cbc-d1ae5e7e444f",
   "metadata": {
    "ExecutionIndicator": {
     "show": false
    },
    "execution": {
     "iopub.execute_input": "2024-01-13T05:09:23.658337Z",
     "iopub.status.busy": "2024-01-13T05:09:23.657763Z",
     "iopub.status.idle": "2024-01-13T05:09:49.419554Z",
     "shell.execute_reply": "2024-01-13T05:09:49.418841Z",
     "shell.execute_reply.started": "2024-01-13T05:09:23.658306Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'杂耍者可以杂耍16个球，其中一半的球是高尔夫球，所以有16/2 = 8个高尔夫球。由于其中一半的高尔夫球是蓝色的，所以有8/2 = 4个蓝色的高尔夫球。所以总共有4个蓝色的高尔夫球。'"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages=[\n",
    "        {\"role\":\"user\", \"content\":\"杂耍者可以杂耍16个球，其中一半的球是高尔夫球，其中一半的高尔夫球是蓝色的。请问总有多少个蓝色的高尔夫球\"}\n",
    "    ]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)\n",
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "01feaa5a-d3c6-4af9-97ac-d44cb04618be",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2024-01-13T05:16:08.322625Z",
     "iopub.status.busy": "2024-01-13T05:16:08.322167Z",
     "iopub.status.idle": "2024-01-13T05:16:30.824391Z",
     "shell.execute_reply": "2024-01-13T05:16:30.822993Z",
     "shell.execute_reply.started": "2024-01-13T05:16:08.322599Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'艾米花了1分钟才滑下来，所以她还有3分钟的时间可以滑下来。水滑梯将在15分钟后关闭，所以在15分钟内她可以滑2次（4分钟 - 1分钟 - 1分钟 = 2次）。所以，在关闭之前她可以滑2次。'"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages=[\n",
    "    {\"role\":\"user\", \"content\":\"艾米需要4分钟才能爬到滑滑梯顶部，她花了1分钟才滑下来，水滑梯将在15分钟后关闭，请问在关闭之前她能滑多少次\"}\n",
    "]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)\n",
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "0bef8d7f-39db-4f0e-a3c6-ac418cbb9975",
   "metadata": {
    "ExecutionIndicator": {
     "show": false
    },
    "execution": {
     "iopub.execute_input": "2024-01-13T05:28:04.771487Z",
     "iopub.status.busy": "2024-01-13T05:28:04.770471Z",
     "iopub.status.idle": "2024-01-13T05:28:04.779976Z",
     "shell.execute_reply": "2024-01-13T05:28:04.777597Z",
     "shell.execute_reply.started": "2024-01-13T05:28:04.771401Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "COT_prompt=' 请一步步思考并得到答案'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "da40b620-2ed3-4e11-acaa-8855fa45b1ee",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T05:28:36.195118Z",
     "iopub.status.busy": "2024-01-13T05:28:36.194389Z",
     "iopub.status.idle": "2024-01-13T05:29:15.813004Z",
     "shell.execute_reply": "2024-01-13T05:29:15.811288Z",
     "shell.execute_reply.started": "2024-01-13T05:28:36.195075Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'首先，罗杰原本有5个网球。\\n\\n接着，他又买了2盒网球，每盒有3个，那么总共买了2盒*3个/盒=6个网球。\\n\\n因此，罗杰现在总共有5个+6个=11个网球。'"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages=[\n",
    "        {\"role\":\"user\", \"content\":\"罗杰有五个网球，他又买了两盒网球，每盒有3个网球，请问他现在总共有多少个网球\"+COT_prompt}\n",
    "    ]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)\n",
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "ad29360b-5cd9-4124-b76c-2e3a83f6c9c4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T05:30:20.011918Z",
     "iopub.status.busy": "2024-01-13T05:30:20.010836Z",
     "iopub.status.idle": "2024-01-13T05:31:01.339709Z",
     "shell.execute_reply": "2024-01-13T05:31:01.338615Z",
     "shell.execute_reply.started": "2024-01-13T05:30:20.011745Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'首先，食堂总共有23个苹果。\\n然后，他们用掉了20个苹果，所以现在食堂里剩下的苹果数量是23-20=3个苹果。\\n接着，他们又买了6个苹果，那么现在食堂里的苹果数量是3+6=9个苹果。\\n所以，现在食堂总共有9个苹果。'"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages=[\n",
    "    {\"role\":\"user\", \"content\":\"食堂总共有23个苹果，如果他们用掉20个苹果，然后又买了6个苹果，请问现在食堂总共有多少个苹果\"+COT_prompt}\n",
    "]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)\n",
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "8e1d0cf5-e94b-4530-ba43-14b1ccad8afc",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2024-01-13T05:33:24.072120Z",
     "iopub.status.busy": "2024-01-13T05:33:24.071545Z",
     "iopub.status.idle": "2024-01-13T05:34:12.906681Z",
     "shell.execute_reply": "2024-01-13T05:34:12.905473Z",
     "shell.execute_reply.started": "2024-01-13T05:33:24.072078Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'杂耍者可以杂耍16个球，其中一半的球是高尔夫球，因此有 16/2 = 8 个高尔夫球。\\n\\n其中一半的高尔夫球是蓝色的，因此有 8/2 = 4 个蓝色的高尔夫球。\\n\\n所以总共有4个蓝色的高尔夫球。'"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages=[\n",
    "        {\"role\":\"user\", \"content\":\"杂耍者可以杂耍16个球，其中一半的球是高尔夫球，其中一半的高尔夫球是蓝色的。请问总有多少个蓝色的高尔夫球\"+COT_prompt}\n",
    "    ]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)\n",
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "66f349f3-b803-487b-b0cd-aee7d91ac334",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-01-13T05:35:10.805754Z",
     "iopub.status.busy": "2024-01-13T05:35:10.804963Z",
     "iopub.status.idle": "2024-01-13T05:36:16.913068Z",
     "shell.execute_reply": "2024-01-13T05:36:16.911078Z",
     "shell.execute_reply.started": "2024-01-13T05:35:10.805691Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1. 艾米花1分钟才滑下来,因此她还有3分钟时间可以滑下来。\\n\\n2. 水滑梯将在15分钟后关闭,因此在这段时间内,艾米最多可以滑两次。\\n\\n3. 由于艾米花了1分钟才滑下来,因此她还有2次机会滑下来。\\n\\n因此,在关闭之前,艾米最多可以滑4次。'"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages=[\n",
    "    {\"role\":\"user\", \"content\":\"艾米需要4分钟才能爬到滑滑梯顶部，她花了1分钟才滑下来，水滑梯将在15分钟后关闭，请问在关闭之前她能滑多少次\"+COT_prompt}\n",
    "]\n",
    "response_glm3 = openai.ChatCompletion.create(model=\"chatglm3-6b\", messages=messages)\n",
    "response_glm3['choices'][0]['message']['content']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8cf2dc3a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "chatglm3-demo",
   "language": "python",
   "name": "chatglm3-demo"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
